﻿namespace Core
{
    public class DialogueInst : Core.Component, IInstruction, IAwake<string>,
        IStartUpdateFinish
    {
        public bool IsComplete { get; protected set; }

        private string message;
        private DialogueSystem sys;

        public void Awake(string message)
        {
            this.message = message;
        }

        public override void Dispose()
        {
            if (IsDisposed) return;
            message = string.Empty;
            base.Dispose();
        }

        public void Start()
        {
            sys = G.Get<DialogueSystem>();
            sys.Push(message);
            IsComplete = false;
        }

        public void Update()
        {
            if (IsComplete) return;
            if (sys.State == 0)
            {
                IsComplete = true;
            }
        }

        public void Finish()
        {

        }
    }
}
